package com.hainatong.shiphelper.mainhome.fragment.massage;

import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.StringUtils;
import com.hainatong.shiphelper.MvvmLazyFragment;
import com.hainatong.shiphelper.R;
import com.hainatong.shiphelper.databinding.FragmentWarnContentBinding;
import com.hainatong.shiphelper.mainhome.entity.MsgBean;
import com.hainatong.shiphelper.utils.GsonUtil;
import com.hainatong.mvvmbase.base.NoViewModel;

import android.os.Bundle;
import android.view.View;

/**
 * 消息 详情
 */
public class WarnMsgDetailFragment extends MvvmLazyFragment<FragmentWarnContentBinding, NoViewModel>
{
    private static String WARN_MSG_TAG = "WarnMsgDetailFragment";

    private MsgBean msgBean;


    public static WarnMsgDetailFragment newInstance(String scanCode)
    {
        Bundle bundle = new Bundle();
        bundle.putString( WARN_MSG_TAG , scanCode );
        WarnMsgDetailFragment msgFragment = new WarnMsgDetailFragment();
        msgFragment.setArguments( bundle );
        return  msgFragment;
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_warn_content;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void initParameters()
    {
        Bundle args = getArguments();
        if(  args != null )
        {
            String msgStr = args.getString(WARN_MSG_TAG , "");
            if(!StringUtils.isEmpty( msgStr ))
            {
                msgBean = GsonUtil.json2Obj( msgStr, MsgBean.class);
            }
        }
    }

    @Override
    protected void onRetryBtnClick()
    {

    }

    @Override
    protected void initView(View view)
    {
    }

    @Override
    protected void lazyLoad()
    {
        if(ObjectUtils.isNotEmpty( msgBean ))
        {
            // 预警详情
            viewDataBinding.tvMsgContent.setText( msgBean.getDetail() );
        }
    }

}
